import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "../modules/store";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import {post, postBody, postBodyByExport,upload} from "./utils/http";
import VueTreeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import md5 from 'js-md5';
import ECharts from 'vue-echarts'; 
require("echarts/lib/component/legend");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/toolbox");
require("echarts/lib/component/title");
require('echarts/map/js/china')
Vue.component('v-chart', ECharts); 
Vue.use(require('vue-electron'))
Vue.config.productionTip = false 

Vue.prototype.$ipcApi = require('./utils/ipcRenderer').default

//指令
import * as directives from './utils/directives'
Object.keys(directives).forEach(k => { 
  Vue.directive(k, directives[k]); 
})  
//过滤器
import * as filter from './utils/filters'
Object.keys(filter).forEach(k => {
  console.log("filter:",k ,"$"+k)
  Vue.filter(k, filter[k]);
  Vue.prototype["$"+k] = filter[k]
})


Vue.component('v-chart', ECharts);
Vue.component('v-treeselect', VueTreeselect )
Vue.use(ElementUI);

Vue.config.productionTip = true;
Vue.prototype.$post = post;
Vue.prototype.$postBody = postBody;
Vue.prototype.$postBodyByExport = postBodyByExport;
Vue.prototype.$upload = upload
Vue.prototype.$md5 = md5;

router.beforeEach((to, from, next) => {
    // ViewUI.LoadingBar.start();
    next();
});

router.afterEach(route => {
    // ViewUI.LoadingBar.finish();
});

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app');
